<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>

<jsp:include page="main.jsp" />

<script>
	function check(){
		var reg = /.*@.*\.(com|cn|org)/;
		var sender = document.getElementById('sender').value;
		var accepter = document.getElementById('accepter').value;
		var theme = document.getElementById('theme').value;
		var contents = document.getElementById('contents').value;
		
			if( sender == '' ){
				document.getElementById('checkSpan').innerHTML = "发件人地址不能为空！";
				return false;
			}else if(sender.length>0 && !reg.test(sender)){
				document.getElementById('checkSpan').innerHTML = "发件人邮箱地址格式不正确！";
				return false;
			}else if( accepter == '' ){
				document.getElementById('checkSpan').innerHTML = "收件人地址不能为空！";
				return false;
			}else if(accepter.length>0 && !reg.test(accepter)){
				document.getElementById('checkSpan').innerHTML = "收件人邮箱地址格式不正确！";
				return false;
			}else if( theme == '' ){
				document.getElementById('checkSpan').innerHTML = "主题不能为空！";
				return false;
			}else if( contents == '' ){
				document.getElementById('checkSpan').innerHTML = "信件内容不能为空！";
				return false;
			}
	
	
	}


</script>
<span style=" font-size:22px; font-weight:500; margin-left:35px;">
		修改草稿
</span>
<s:iterator value="list">
<div style="width: 735px;">
	<form action="EmailWrite.action" method="post" onsubmit="return check();">
		<table width="100%">
			<tr>
				<td width="15%" align="center" valign="middle">
					发件人
				</td>
				<td width="55%" align="left" valign="middle">
					<input type="text" name="sender" id="sender" value="<s:property value="sender"/>" style="width:200px; border:1px solid green"/>
				</td>
				<td  width="30%" rowspan="5" style="border:1px solid black">
					&nbsp;
				</td>
			</tr>
			<tr>
				<td width="15%" align="center" valign="middle">
					收件人
				</td>
				<td width="55%" align="left" valign="middle">
						<input type="text" name="accepter" id="accepter" value="<s:property value="accepter"/>" style="width:200px; border:1px solid green"/>
				</td>
				<td>
					&nbsp;
				</td>
			</tr>
			<tr>
				<td width="15%" align="center" valign="middle">
					主题
				</td>
				<td width="55%" align="left" valign="middle">
					<input type="text" name="theme" id="theme" value="<s:property value="theme"/>" style="width:200px; border:1px solid green"/>
				</td>
				<td>
					&nbsp;
				</td>
			</tr>
			<tr>
				<td width="15%" align="center" valign="middle">内容</td>
				<td width="55%" align="left" valign="middle">
					<textarea rows="8" wrap="hard"  name="contents" id="contents" style="width:350px; border:1px solid green"><s:property value="content"/></textarea>
				</td>
			</tr>
			<tr><td  colspan="2" align="center" valign="middle"><span id="checkSpan" style="color:red"></span></td></tr>
			<tr>
				<td  colspan="3" valign="middle">
					<input type="hidden" name="id" id="id" value="<s:property value="id"/>" />
					<input type="submit" value="发送" style="margin-left:100px"/>
					<input type="submit" value="仅保存" onclick="this.form.action='EmailTestXiu.action'"/>
					<a href="EmailDeleteE.action?id=<s:property value="id"/>" style="margin-left:20px;text-decoration:none;color:black;">删除</a>
					<a href="EmailTest.action" style="margin-left:20px;text-decoration:none;color:black;">返回到草稿箱</a>
				</td>

			</tr>
		</table>
	</form>
</div>
</s:iterator>

<jsp:include page="mainb.jsp" />

